/*
 * @lc app=leetcode.cn id=824 lang=typescript
 *
 * [824] 山羊拉丁文
 */

// @lc code=start
function toGoatLatin(sentence: string): string {
    const head = ["a", "e", "i", "o", "u"];
    return sentence
        .split(" ")
        .map((i, index) => {
            const tail = Array(index + 1)
                .fill("a")
                .join("");
            if (head.includes(i[0].toLowerCase())) {
                return i + "ma" + tail;
            } else {
                return i.substring(1) + i[0] + "ma" + tail;
            }
        })
        .join(" ");
}
// @lc code=end
